<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>平库入库</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">入库组盘</h1>
		</header>
		<div class="mui-content">
			
			<input id="boxCodeInput" type="text" class="mui-input-clear" placeholder="托盘条码"  >
			 
			<ul id="OA_task_2" class="mui-table-view">
			</ul>
			<h5 class="mui-content-padded" style="margin: 15px 10px;">备选明细</h5>
			<ul id="OA_task_1" class="mui-table-view">
			</ul>

			<div id="removeTmp" style="visibility: hidden;">
				<div style="display: none;">sgj_id</div>
				<!-- <div class="mui-slider-left mui-disabled">
					<a class="mui-btn mui-btn-red">删除</a>
				</div> -->
				<div class="mui-slider-right mui-disabled">
					<a class="mui-btn mui-btn-red">删除</a>
				</div>
				<div class="mui-slider-handle">
					sgj_data
				</div>
			</div>
			<div id="addTmp" style="visibility: hidden;">
				<div style="display: none;">sgj_id</div>
				<!-- <div class="mui-slider-left mui-disabled">
					<a class="mui-btn mui-btn-red">绑定</a>
				</div> -->
				<div class="mui-slider-right mui-disabled">
					<a class="mui-btn mui-btn-red">绑定</a>
				</div>
				<div class="mui-slider-handle">
					sgj_data
				</div>
			</div>

		</div>

	</body>
	<script src="../js/mui.js"></script>
	<script src="kj.js"></script>
	<script>
		mui.init();  
		var deleteDet=confirmEvent('确认删除该条记录？',function(elem){
			myPost("CoreStockDet/setDetailStock", { id: elem.children[0].innerHTML }, function(response) {
						queryAll()
			}); 
		}) 
		var addDet = confirmEvent('确认绑定该条记录？', function(elem) {  
			myPost("pda/bandDetPingku/"+elem.children[0].innerHTML+"/"+selectStock.id, {}, function(data) {
				mui.toast( data)
				queryAll();
						 
			});
		});
		 
		mui('#OA_task_2').on('slideleft', '.mui-table-view-cell', deleteDet);
		mui('#OA_task_2').on('slideright', '.mui-table-view-cell', deleteDet);

		mui('#OA_task_1').on('slideleft', '.mui-table-view-cell', addDet);
		mui('#OA_task_1').on('slideright', '.mui-table-view-cell', addDet);
	</script>

	<script>
		document.getElementById("boxCodeInput").addEventListener('input', function(event) {
			if(this.value.length>4){
				queryAll(  )
			}
		}, false);		
		function queryAll( ){
			var value=document.getElementById("boxCodeInput").value
			myGet("pda/getStock/"+value, function(data) { 
				selectStock= data.main ;
				appendChind('#OA_task_2',data.detList,"#removeTmp");
			}); 
			myPost("CoreStockDet/findDetailPage", { pid: 0, storeStatus: 3, pageNum: 1, pageSize: 200 }, function(data) {  
					appendChind('#OA_task_1', data.content, "#addTmp"); 
			}, "json");
		}
		function appendChind(eleId,list,tmp){
			var content = document.body.querySelector(eleId);
			content.innerHTML = ""
					
			for(var i=0;i<list.length;i++){
				var det=list[i] 
				var info = getItem(det.itemId)  ; 
				info+= "（"+det.countDb+")"
				if(det.status==3){
					info+="库外" 
				}else if(det.status==29){
					info+="库存"
				}	
				var html=document.body.querySelector(tmp).innerHTML
				var data= html.replace("sgj_data",info).replace("sgj_id",det.id)
				var li = document.createElement('li');
				li.className = "mui-table-view-cell";
				li.innerHTML = data
				content.appendChild(li)
			}
		}
		
	
		</script>
</html>